﻿/*-----------------------------------------------------------------------
 * <copyright file="Converter.cs" company="O-RID">
 *     Copyright (c)2010 O-RID Co.,Ltd.
 * </copyright>
 * <author>Li Dawei&Zhang Jun</author>
 * <summary>
 *          根据datagrid内容改变样式
 *          作成日： 07/28/2010
 *
 * </summary>
 *-----------------------------------------------------------------------
 */
namespace Orid.Management.Statistics.OperatorUnitMangement.Common.SytleSet
{
    using System;
    using System.Globalization;
    using System.Windows.Data;
    using System.Windows.Media;

    /// <summary>
    /// 自定义 动态样式转换 O：紫色  X：灰色
    /// 只能用在DataGridTemplateColumn的形式中
    /// 使用DataGridTemplate，放入TextBlock，Foregroud屬性Binding目标值
    /// </summary>
    public class ColorConverter : IValueConverter
    {
        /// <summary>
        /// 在将源数据传递到目标以在 UI 中显示之前，对源数据进行修改。
        /// </summary>
        /// <param name="value">正传递到目标的源数据。</param>
        /// <param name="targetType">目标依赖项属性需要的数据的 System.Type。</param>
        /// <param name="parameter">要在转换器逻辑中使用的可选参数。</param>
        /// <param name="culture">转换的区域性。</param>
        /// <returns>要传递到目标依赖项属性的值。</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string str = (string)value;
            Color color = str == "O" ? Colors.Magenta: Colors.DarkGray;
            return new SolidColorBrush(color);
        }

        /// <summary>
        /// Converts the back.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="culture">The culture.</param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

    }

}
